const path = require('path')
const { config } = require('process')
const port = process.env.port || process.env.npm_config_port || 8282
const name = '后台管理系统'
function resolve(dir) {
    return path.join(__dirname, dir)
}
module.exports = {
    lintOnSave: false,
    publicPath: process.env.NODE_ENV === 'production' ? '/' : '/',
    outputDir: 'dist',
    assetsDir: 'static',
    productionSourceMap: false,
    devServer: {
        host: 'localhost',
        port: port,
        open: true,
        proxy: {
            '/api': {
                target: process.env.VUE_APP_API,
                changeOrigin: true,
                pathRewrite: {
                    '^/api': '',
                },
            },
        },
    },
    chainWebpack: (config) => {
        config.resolve.symlinks(true)
        config.resolve.alias.set('@', resolve('src'))
        config.plugin('html').tap((options) => {
            options[0].title = name
            return options
        })
    },
    configureWebpack: {
        devtool: 'source-map',
    },
}
